//
//  main.m
//  Day8
//
//  Created by dllo on 16/5/13.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    
#pragma mark - 结构体基本概念
    // 结构体:用于盛放不同数据类型的自定义数据类型.是一种构造类型
    
    // 结构体的基本格式  结构体名首字母要大写
//    struct 结构体名 {
//        数据类型 变量名;
//    };
#if 0
    struct Person {
        int age;
        float height;
    };
    
    //定义结构体变量
    //1.先定义结构体类型,再定义结构体变量
    
    struct Person p;
#endif
    
    
#if 0
    // 2.定义结构体类型的同时定义变量
    struct Person {
        int age;
        float height;
    } wang;
    
    
#endif
    
    
#if 0
    // 3.定义结构体的类型的同时定义变量,省略结构体名(匿名结构体)
    struct {
        int age;
        float height;
    } wang;
    
    
    
    
    
#endif
    
#if 0
 //   typedef 原数据类型名 别名
    // 1.对已有进行重定义
    typedef struct Teacher Driver;
    
    struct Teacher {
        char name[20];
        char sex[20];
        int age;
        int workNumber;
    };
    struct Teacher teacherSi;
    
    struct Student {
        char name[20];
        char sex[20];
        int age;
        int stuNumber;
    };
    
    struct Student studentSi;
    
    Driver teacher;
    
    
    
    
    
    
#endif
    
    
#if 0
    // 2. 在创建结构体时进行重定义
    typedef struct teacher {
        int age;
        char name[20];
        
    } Teacher;
    
    Teacher wang;
    
    
    typedef struct teacher Teacher;
   
    typedef struct  student {
        int age;
        char name[];
    } Student ;
    
    
    typedef struct student Xstudent;
    
    Xstudent  kora;
    kora.age = 7;
    
    
    
    
    
    
    
#endif
    
#if 0
#pragma mark - 结构体成员赋值
    int x[5] = {1,2,3,4,5};
    typedef struct teacher {
        int age;
        char name[20];
    }Teacher;
    
    Teacher wang = {30, "wang"};
    Teacher li;
    li = wang;
    
    
    // 通过.找到结构体成员  然后赋值  . 可以理解成"的"
    wang.age = 40;
//      wang.name = "wang";   //这是非法的
    
//    strcpy(wang.name, "laowang");
    
    printf("name = %s\n", wang.name);
    // 结构体赋值给结构体   是值的传递
    printf("name = %s\n", li.name);
    
#endif

#if  0
    struct teacher {
        char name[20];
        int age;
        int number;
    };
    
    struct teacher kora = {"kora",20,6533};
    strcpy(kora.name, "sera");
    
    printf("%s\n",kora.name);
    
    typedef struct teacher Teacher;
    
    Teacher tony;
    tony.age = 42;
    
    
    
    
#endif
    
#pragma mark - 结构体内存
    
#if 0
    typedef struct Student {
        int age;
        char name;
        double height;
    }Student;
    
    Student wang;
    
#endif
    
#pragma mark - 结构体嵌套
//    
//    typedef struct Date {
//        int year;
//        int month;
//        int day;
//        
//    }Date;
//    
//    typedef struct Person {
//        int age;
//        char name[5];
//        Date birthday;
//    }Person;
//    
//    
//    Person wang = {30, "wang", {1986, 4, 10}};
//    wang.birthday.year = 1986;
//    Person li;
//    Person zhang;
//    
//#pragma mark - 结构体数组
//    //结构体数组
//    Person a[3] = {wang,li,zhang};
//    
//    a[1].age = 20;
//    strcpy(a[1].name, "li");
//    a[1].birthday.year = 1996;
//    a[1].birthday.month = 4;
//    a[1].birthday.day = 13;
//    
    

    int i,j , a = 0 ; for ( i = 0 ; i < 2 ; i++){ for ( j = 0 ; j < 4 ; j ++ ) { if ( j % 2 ) break ; a++ ;} a++; } printf ( " % d " , a ) ;
    
    return 0;
}
